<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>学习Events</title>
	</head>
	<body>
		<div style="padding-top: 50px;height: 1000px;">
		</div>
		<script>
			document.addEventListener( "plusready", function(){
			  // 扩展API加载完毕，现在可以正常调用扩展API
				alert("扩展API加载完毕")
				document.addEventListener("plusscrollbottom", onScrollToBottom, false);
			}, false );
			
			document.addEventListener("pause", function(){
				//从前台切换到后台
				alert("从前台切换到后台")
			}, false);
			
			document.addEventListener("resume", function(){
				//从前台切换到后台
				alert("运行环境从后台切换到前台事件")
			}, false);
			
			document.addEventListener("netchange", function(){
				//网络状态变化
				onNetChange()
			}, false);
			
			document.addEventListener("plusscrollbottom", function(){
				//网络状态变化
				onScrollToBottom()
			}, false);
			function onScrollToBottom(){
				alert("页面滚动到底部事件")
			}
			
			function onNetChange(){
				var nt = plus.networkinfo.getCurrentType();
				switch (nt){
					case plus.networkinfo.CONNECTION_ETHERNET:
					case plus.networkinfo.CONNECTION_WIFI:
					alert("Switch to Wifi networks!"); 
					break; 
					case plus.networkinfo.CONNECTION_CELL2G:
					case plus.networkinfo.CONNECTION_CELL3G:
					case plus.networkinfo.CONNECTION_CELL4G:
					alert("Switch to Cellular networks!");  
					break; 
					default:
					alert("Not networks!"); 
					break;
				}
			}
			
			
			
			

		</script>
	</body>
</html>
